/*    */ package com.zimbra.qa.unittest;
/*    */ 
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.mailbox.MailItem;
/*    */ import com.zimbra.cs.mailbox.MailItem.Type;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.Message;
/*    */ import com.zimbra.cs.stats.ZimbraPerf;
/*    */ import java.util.List;
/*    */ import junit.framework.TestCase;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestItemCache
/*    */   extends TestCase
/*    */ {
/*    */   private Mailbox mMbox;
/*    */   private Account mAccount;
/*    */   
/*    */   protected void setUp()
/*    */     throws Exception
/*    */   {
/* 41 */     ZimbraLog.test.debug("TestTags.setUp()");
/* 42 */     super.setUp();
/*    */     
/* 44 */     this.mAccount = TestUtil.getAccount("user1");
/* 45 */     this.mMbox = MailboxManager.getInstance().getMailboxByAccount(this.mAccount);
/*    */   }
/*    */   
/*    */ 
/*    */   public void testCacheHit()
/*    */     throws Exception
/*    */   {
/* 52 */     ZimbraLog.test.debug("testCacheHit");
/*    */     
/* 54 */     List<MailItem> messages = this.mMbox.getItemList(null, MailItem.Type.MESSAGE);
/* 55 */     assertTrue("No messages found", messages.size() > 0);
/* 56 */     Message msg = (Message)messages.get(0);
/* 57 */     this.mMbox.getItemById(null, msg.getId(), msg.getType());
/*    */     
/* 59 */     int prepareCount = ZimbraPerf.getPrepareCount();
/* 60 */     for (int i = 1; i <= 10; i++) {
/* 61 */       this.mMbox.getItemById(null, msg.getId(), msg.getType());
/*    */     }
/*    */     
/* 64 */     prepareCount = ZimbraPerf.getPrepareCount() - prepareCount;
/* 65 */     assertEquals("Detected unexpected SQL statements.", 0, prepareCount);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestItemCache.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */